#ifndef TEXTURETILESTATE
#define TEXTURETILESTATE

#include <boost/shared_ptr.hpp>

#include <base\vec2i.h>
#include <app\states\sessionState.h>

#ifdef CLIENT
#include <render\levels\tile.h>
#endif

#include <Poco\File.h>
#include <string>

namespace nTextureTile {
  enum eTextureTile {
    READY = 1,
    TRANSFERRING = 2,
    TRANSFERRED = 3
  };
};

struct sTextureTile {
  int x;
  int y;
  int level;
  nTextureTile::eTextureTile status;

  sTextureTile() : x(0), y(0), level(0) {
    status = nTextureTile::READY;
  }
};

class textureTileState : public sessionState {

  static int class_type_id;
  int type_id;

  sTextureTile texture_tile_desc;

  #ifdef CLIENT
  boost::shared_ptr<tile> *caller;
  #endif

public:

  static sessionState *create();

  bool isReady();
  void setState(nTextureTile::eTextureTile s);
  #ifdef SERVER
  void requestTextureTile(int x, int y, int level);
  #endif
  #ifdef CLIENT
  void requestTextureTile(int x, int y, int level, tile * caller_);
  void receivedTextureTile(int x, int y, int level, unsigned char *data, int size);
  #endif

  static int getClassTypeId();
  virtual int getTypeId();

  textureTileState();
  virtual ~textureTileState();
};

#endif